<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<% String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";%>
<html>
<head>
    <base href="<%=basePath%>">
    <script src="/js/jquery.min.js"></script>
    <script type="text/javascript">
        function del() {
            if (confirm("确定要删除吗？\n\n请确认！") == true) {
                if (confirm("用户信息删除后将无法恢复，确定要删除吗？\n\n请确认！") == true)
                    return true;
            }
            return false;
        };
        $(function () {
            //新建

            $("#new").click(function () {
                window.location.href = "admin/useradd.jsp";
            })
            //查询
            $("#search").click(function () {
                window.location.href = "admin/usersearch.jsp";
            })
        });
    </script>
</head>
<body>
<jsp:include page="/admin/top.jsp"/>
<!-- 表头 -------------------------------------------------------------------->
<div class="middle listbox">
    <button id="new">新建</button>
    <button id="search">查询</button>
</div>
<!-- 表头 --------------------------------------------------------------------->
<div class="middle" style="height:200px">
    <table class="middle list">
        <thead>
        <tr>
            <th width=5%>序号</th>
            <th width="15%">ID</th>
            <th width="10%">姓名</th>
            <th width="5%">性别</th>
            <th width="20%">E-mail</th>
            <th width="15%">电话</th>
            <th width="15%">邮编</th>
            <th width="10%">状态</th>
            <th width="10%">操作</th>
        </tr>
        </thead>
        <tbody>
        <c:set var="i" value="${(page.pageNum-1)*page.pageSize}"/>
        <c:forEach items="${list}" var="user">
            <tr>
                <td width="5%">
                    <c:set var="i" value="${i+1 }"/>
                    <c:out value="${i}"/>
                </td>
                <td width="15%">
                    <a href="admin/userinfo?userid=${user.userid}">${user.userid}</a>
                </td>
                <td width="10%">${user.username}</td>
                <td width="5%">${user.gender}</td>
                <td width="20%">${user.email}</td>
                <td width="15%">${user.phone}</td>
                <td width="15%">${user.postcode}</td>
                <td width="10%">
                    <c:choose>
                        <c:when test="${user.state==1}">激活</c:when>
                        <c:when test="${user.state==0}">未激活</c:when>
                    </c:choose>
                </td>
                <td width="10%">
                    <a href="admin/userdel?op=del&userid=${user.userid}" onclick="return del();">删除</a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
<!-- 页码 --------------------------------------------------------------->
<div class="middle listbox">
    共${page.pages}页 &nbsp;
    <c:forEach begin="1" end="${page.pages}" var="i">
        <c:choose>
            <c:when test="${page.pageNum==i}"><span style="font-weight: bold">${i}</span></c:when>
            <c:when test="${page.pageNum!=i}"><a href="admin/usersearch?pageNum=${i}">
                <span style="font-weight: bold;text-decoration: underline">${i}</span>
            </a></c:when>
        </c:choose>
    </c:forEach>
</div>
<!-- 页码 ---------------------------------------------------------------->
<jsp:include page="/admin/bottom.jsp"/>
</body>
</html>